package com.md24housecall.adapter;

import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.md24housecall.activity.R;
import com.md24housecall.model.IHealthDataList;

public abstract class BaseIHealthAdapter extends BaseAdapter{

	protected Context mContext;
	protected List<IHealthDataList> listBpData;
	protected Calendar calendar=Calendar.getInstance(TimeZone.getTimeZone("UTC"));
	protected final String TIMEFORMAT="dd/MM/yy hh:mm:ss aa";
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listBpData.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listBpData.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public void updateData(List<IHealthDataList>listData){
		this.listBpData=listData;
	}
	
	public abstract void fillData(ViewHolder viewHolder,int position);
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View rowView = convertView;
		ViewHolder viewHolder;
		if (rowView == null) {
			LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			rowView = inflater.inflate(R.layout.ihealth_data_item, null);
			viewHolder = new ViewHolder();
			viewHolder.txvDate = (TextView) rowView.findViewById(R.id.txvDate);
			viewHolder.txvColumn1 = (TextView) rowView.findViewById(R.id.txvColumn1);
			viewHolder.txvColumn2 = (TextView) rowView.findViewById(R.id.txvColumn2);
			rowView.setTag(viewHolder);
		}
		viewHolder = (ViewHolder) rowView.getTag();
		if(position<listBpData.size())
			fillData(viewHolder,position);
		return rowView;
	}

	public static class ViewHolder {
		public TextView txvDate;
		public TextView txvColumn1;
		public TextView txvColumn2;
	}
}
